package com.miku.sys.utils;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.web.util.SavedRequest;
import org.apache.shiro.web.util.WebUtils;
import org.junit.Test;

public class URLUtils {
	public static String getAuthLastRequestURL(HttpServletRequest request){
		SavedRequest sr = WebUtils.getSavedRequest(request);
		if(sr != null)
			return sr.getRequestUrl();
		return null;
	}
	
	public static String clipURLRemoveDomain(String url){
		if(url == null) return "/";
		
		if(url.startsWith("http")){
			int p = url.indexOf("/", 8);
			if(p != -1)
				return url.substring(p);
			else
				return "/";
		}
		return url;
	}
	
	@Test
	public void aa(){
		System.out.println(clipURLRemoveDomain("https://www.jintipu.com"));
	}
}
